package com.ruoyi.cat.service.impl;

import java.util.Collections;
import java.util.List;

import com.ruoyi.cat.domain.CatChance;
import com.ruoyi.cat.domain.DTO.ChanceDataDTO;
import com.ruoyi.cat.mapper.CatChanceMapper;
import com.ruoyi.cat.service.ICatChanceService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 抽奖机会Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-30
 */
@Service
public class CatChanceServiceImpl implements ICatChanceService
{
    @Autowired
    private CatChanceMapper catChanceMapper;

    /**
     * 查询抽奖机会
     * 
     * @param id 抽奖机会主键
     * @return 抽奖机会
     */
    @Override
    public CatChance selectCatChanceById(Long id)
    {
        return catChanceMapper.selectCatChanceById(id);
    }

    /**
     * 查询抽奖机会列表
     * 
     * @param catChance 抽奖机会
     * @return 抽奖机会
     */
    @Override
    public List<CatChance> selectCatChanceList(CatChance catChance)
    {
        return catChanceMapper.selectCatChanceList(catChance);
    }

    /**
     * 新增抽奖机会
     * 
     * @param catChance 抽奖机会
     * @return 结果
     */
    @Override
    public int insertCatChance(CatChance catChance)
    {
        catChance.setCreateTime(DateUtils.getNowDate());
        return catChanceMapper.insertCatChance(catChance);
    }

    /**
     * 修改抽奖机会
     * 
     * @param catChance 抽奖机会
     * @return 结果
     */
    @Override
    public int updateCatChance(CatChance catChance)
    {
        return catChanceMapper.updateCatChance(catChance);
    }

    /**
     * 批量删除抽奖机会
     * 
     * @param ids 需要删除的抽奖机会主键
     * @return 结果
     */
    @Override
    public int deleteCatChanceByIds(Long[] ids)
    {
        return catChanceMapper.deleteCatChanceByIds(ids);
    }

    /**
     * 删除抽奖机会信息
     * 
     * @param id 抽奖机会主键
     * @return 结果
     */
    @Override
    public int deleteCatChanceById(Long id)
    {
        return catChanceMapper.deleteCatChanceById(id);
    }

    @Override
    public List<ChanceDataDTO> getChanceData(Long articleId) {
        return catChanceMapper.getChanceData(articleId);
    }

    @Override
    public Long getChanceDataByUserId(Long articleId,Long userId) {
        return catChanceMapper.getChanceDataByUserId(articleId,userId);
    }

    @Override
    public Long getChanceDataByUserIdAndUserId(Long articleId, Long userId) {
        return catChanceMapper.getChanceDataByUserIdAndUserId(articleId,userId);
    }

    @Override
    public int updateRemainingChances(CatChance catChance) {
        return catChanceMapper.updateRemainingChances(catChance);
    }
}
